Imports System.Diagnostics.Process
Imports System.Threading
Public Class F_SalesOrder
    Dim WithEvents SBO_Application As SAPbouiCOM.Application
    Dim Ocompany As SAPbobsCOM.Company
    Sub New(ByVal ocompany1 As SAPbobsCOM.Company, ByVal sbo_application1 As SAPbouiCOM.Application)
        SBO_Application = sbo_application1
        Ocompany = ocompany1
    End Sub

    Private Sub SBO_Application_FormDataEvent(ByRef BusinessObjectInfo As SAPbouiCOM.BusinessObjectInfo, ByRef BubbleEvent As Boolean) Handles SBO_Application.FormDataEvent
        Try
            If BusinessObjectInfo.FormTypeEx = 139 Then
                If BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD And BusinessObjectInfo.BeforeAction = True Then
                    oForm = SBO_Application.Forms.Item(BusinessObjectInfo.FormUID)
                    'Add Container details
                    Add_Container_details(oForm)
                    Add_Cargo_details(oForm)
                End If
                If BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_UPDATE And BusinessObjectInfo.BeforeAction = True Then
                    oForm = SBO_Application.Forms.Item(BusinessObjectInfo.FormUID)
                    ' Update Container details
                    Update_Container_details(oForm)
                    Update_Cargo_details(oForm)
                End If
                If BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD And BusinessObjectInfo.ActionSuccess = True And BusinessObjectInfo.BeforeAction = False Then
                    oForm = SBO_Application.Forms.Item(BusinessObjectInfo.FormUID)
                    Get_Container_details(oForm)
                    Get_Cargo_details(oForm)
                    'Load Container details 
                End If

            End If


        Catch ex As Exception
            SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)
        End Try
    End Sub
    Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
        Try
            If pVal.FormType = 139 Then
                If pVal.EventType = SAPbouiCOM.BoEventTypes.et_COMBO_SELECT Then
                    If pVal.Before_Action = False And pVal.InnerEvent = False And (pVal.FormMode = SAPbouiCOM.BoFormMode.fm_ADD_MODE Or pVal.FormMode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE) Then
                        oForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)
                        '  oForm.PaneLevel = 12
                        If pVal.ItemUID = "e3" Then
                            oCombo = oForm.Items.Item("e3").Specific
                            oEdit = oForm.Items.Item("e33").Specific
                            oEdit.String = oCombo.Selected.Description
                        ElseIf pVal.ItemUID = "e13" Then
                            oCombo = oForm.Items.Item("e13").Specific
                            oEdit = oForm.Items.Item("e14").Specific
                            oEdit.String = oCombo.Selected.Description
                        End If
                    End If
                ElseIf pVal.EventType = SAPbouiCOM.BoEventTypes.et_VALIDATE Then
                    If pVal.Before_Action = False And pVal.InnerEvent = False And (pVal.FormMode = SAPbouiCOM.BoFormMode.fm_ADD_MODE Or pVal.FormMode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE) Then
                        If pVal.ItemUID = "MATCont" And pVal.ColUID = "ContNo" Then
                            oMatrix1 = oForm.Items.Item("MATCont").Specific
                            oEdit = oMatrix1.Columns.Item("ContNo").Cells.Item(oMatrix1.RowCount).Specific
                            If oEdit.String <> "" Then
                                oMatrix1.AddRow()
                                oMatrix1.ClearRowData(oMatrix1.RowCount)
                            End If
                        ElseIf pVal.ItemUID = "MATCargo" And pVal.ColUID = "SupCode" Then
                            'MATCargo
                                oMatrix = oForm.Items.Item("MATCargo").Specific
                            oEdit = oMatrix.Columns.Item("SupCode").Cells.Item(oMatrix.RowCount).Specific
                            If oEdit.String <> "" Then
                                oMatrix.AddRow()
                                oMatrix.ClearRowData(oMatrix.RowCount)
                            End If

                        ElseIf pVal.ItemUID = "MATCargo" And pVal.ColUID = "H" Then

                            'Gopinath
                            Dim l As Integer = 0
                            Dim w As Integer = 0
                            Dim h As Integer = 0
                            Dim wt As Double = 0
                            Dim vol As Double = 0
                            Dim m3 As Double = 0
                            oEdit = oMatrix.Columns.Item("L").Cells.Item(pVal.Row).Specific
                            If oEdit.String <> "" Then
                                l = oEdit.Value
                            Else
                                l = 0
                            End If
                            oEdit = oMatrix.Columns.Item("W").Cells.Item(pVal.Row).Specific
                            If oEdit.String <> "" Then
                                w = oEdit.Value
                            Else
                                w = 0
                            End If
                            oEdit = oMatrix.Columns.Item("H").Cells.Item(pVal.Row).Specific
                            If oEdit.String <> "" Then
                                h = oEdit.Value
                            Else
                                h = 0
                            End If
                            Try
                                m3 = ((l / 100) * (w / 100) * (h / 100))
                            Catch ex As Exception
                                m3 = 0
                            End Try
                            oEdit = oMatrix.Columns.Item("m3").Cells.Item(pVal.Row).Specific
                            oEdit.String = m3
                            oEdit = oMatrix.Columns.Item("Wt").Cells.Item(pVal.Row).Specific
                            If oEdit.String <> "" Then
                                wt = oEdit.Value
                            Else
                                wt = 0
                            End If
                            If m3 > wt Then
                                oEdit = oMatrix.Columns.Item("vol").Cells.Item(pVal.Row).Specific
                                oEdit.String = m3
                            Else
                                oEdit = oMatrix.Columns.Item("vol").Cells.Item(pVal.Row).Specific
                                oEdit.String = wt
                            End If
                            'oForm.Items.Item("MATCargo").Specific.Columns.item("Wt").DataBind.Bind("OCARGO1", "U_Wt")
                            'oForm.Items.Item("MATCargo").Specific.Columns.item("L").DataBind.Bind("OCARGO1", "U_Len")
                            'oForm.Items.Item("MATCargo").Specific.Columns.item("W").DataBind.Bind("OCARGO1", "U_Width")
                            'oForm.Items.Item("MATCargo").Specific.Columns.item("H").DataBind.Bind("OCARGO1", "U_Height")
                            'oForm.Items.Item("MATCargo").Specific.Columns.item("m3").DataBind.Bind("OCARGO1", "U_M3")
                            'oForm.Items.Item("MATCargo").Specific.Columns.item("vol").DataBind.Bind("OCARGO1", "U_Vol")
                        End If

                    End If
                End If

                If pVal.ItemUID = "Genera1" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.Before_Action = False Then
                    oForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)
                    oForm.PaneLevel = 12
                    'ElseIf pVal.ItemUID = "Cargo" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.Before_Action = True Then

                ElseIf pVal.ItemUID = "Cargo" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.Before_Action = True Then
                    oForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)
                    'oForm.Freeze(True)
                    ' If pVal.FormMode = SAPbouiCOM.BoFormMode.fm_OK_MODE Then
                    ' oForm.Mode = SAPbouiCOM.BoFormMode.fm_OK_MODE
                    'End If

                    oForm.PaneLevel = 13
                    ' oForm.Freeze(False)
                    'Cont
                ElseIf pVal.ItemUID = "Cont" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.Before_Action = True Then
                    oForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)
                    'oForm.Freeze(True)
                    oForm.PaneLevel = 15
                    ' oForm.Freeze(False)
                    'If pVal.FormMode = SAPbouiCOM.BoFormMode.fm_OK_MODE Or pVal.FormMode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE Then
                    '    'Get_Container_details(oForm)
                    'End If
                    'Charge1
                ElseIf pVal.ItemUID = "Charge1" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.Before_Action = False Then
                    SBO_Application.ActivateMenuItem("47641")
                ElseIf pVal.ItemUID = "Charge2" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.Before_Action = False Then
                    SBO_Application.ActivateMenuItem("47642")
                End If
                If pVal.ItemUID = "e2" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_VALIDATE And pVal.Before_Action = False And pVal.InnerEvent = False Then
                    oForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)
                    oEdit = oForm.Items.Item("e2").Specific
                    Dim ItemCode As String = oEdit.String
                    If ItemCode <> "" Then
                        oEdit = oForm.Items.Item("e22").Specific
                        oEdit.String = ItemName(ItemCode, Ocompany)
                    End If


                End If
                If ((pVal.EventType <> SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD) And (pVal.Before_Action = True)) Then
                    oOrderForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)
                    If ((pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD) And (pVal.Before_Action = True)) Then
                        oOrderForm.DataSources.DataTables.Add("OCARGO")
                        oOrderForm.DataSources.DataTables.Add("OCARGO1")
                        oItem = oOrderForm.Items.Item("114")
                        oItem.Visible = False
                        oForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)


                        oNewItem = oOrderForm.Items.Add("Charge1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
                        oItem = oOrderForm.Items.Item("2")
                        oNewItem.Top = oItem.Top
                        oNewItem.Height = oItem.Height
                        oNewItem.Width = oItem.Width + 60
                        oNewItem.Left = oItem.Left + oItem.Width + 5
                        oButton = oNewItem.Specific
                        oButton.Caption = "Load Charge Code"
                        oNewItem = oOrderForm.Items.Add("Charge2", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
                        oItem = oOrderForm.Items.Item("Charge1")
                        oNewItem.Top = oItem.Top
                        oNewItem.Height = oItem.Height
                        oNewItem.Width = oItem.Width + 20
                        oNewItem.Left = oItem.Left + oItem.Width + 5
                        oButton = oNewItem.Specific
                        oButton.Caption = "Load Handling Charge Code"


                        oNewItem = oOrderForm.Items.Add("Genera1", SAPbouiCOM.BoFormItemTypes.it_FOLDER)
                        oItem = oOrderForm.Items.Item("112")
                        oNewItem.Top = oItem.Top
                        oNewItem.Height = oItem.Height
                        oNewItem.Width = oItem.Width
                        oNewItem.Left = oItem.Left - 5
                        oFolderItem = oNewItem.Specific
                        oFolderItem.Caption = "Genera1"
                        oFolderItem.GroupWith("112")
                        oFolderItem.Pane = 12
                        oFolderItem.Select()

                        '===============================================
                        oItem = oOrderForm.Items.Item("18")
                        oNewItem = oOrderForm.Items.Add("e1", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = 80 'oItem.Width
                        oNewItem.Top = oItem.Top
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oCombo = oNewItem.Specific
                        oCombo.DataBind.SetBound(True, "ORDR", "U_AB_Divison")
                        'ComboLoad_Division(oForm, oCombo)
                        oItem = oOrderForm.Items.Item("19")
                        oNewItem = oOrderForm.Items.Add("s1", SAPbouiCOM.BoFormItemTypes.it_STATIC)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = oItem.Width '+ 85
                        oNewItem.Top = oItem.Top
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oNewItem.LinkTo = "e1"
                        oStatic = oNewItem.Specific
                        oStatic.Caption = "Division"
                        '  Exit Sub
                        '===============================================

                        'ComboLoad_Division(oForm, oCombo)
                        oItem = oOrderForm.Items.Item("e1")
                        oNewItem = oOrderForm.Items.Add("s9", SAPbouiCOM.BoFormItemTypes.it_STATIC)
                        oNewItem.Left = oItem.Left + 10 + oItem.Width
                        oNewItem.Width = oItem.Width '+ 85
                        oNewItem.Top = oItem.Top
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        ' oNewItem.LinkTo = "e1"
                        oStatic = oNewItem.Specific
                        oStatic.Caption = "Transfer To"

                        oItem = oOrderForm.Items.Item("s9")
                        oNewItem = oOrderForm.Items.Add("e9", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX)
                        oNewItem.Left = oItem.Width + oItem.Left + 10
                        oNewItem.Width = 80 'oItem.Width
                        oNewItem.Top = oItem.Top
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oCombo = oNewItem.Specific
                        oCombo.DataBind.SetBound(True, "ORDR", "U_AB_TransTo")
                        ComboLoad_TransferTo(oOrderForm, oCombo)
                        oItem = oOrderForm.Items.Item("s9")
                        oItem.LinkTo = "e9"
                        '  Exit Sub

                        oItem = oOrderForm.Items.Item("e9")
                        oNewItem = oOrderForm.Items.Add("s10", SAPbouiCOM.BoFormItemTypes.it_STATIC)
                        oNewItem.Left = oItem.Left + 10 + oItem.Width
                        oNewItem.Width = oItem.Width + 20 '+ 85
                        oNewItem.Top = oItem.Top
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        ' oNewItem.LinkTo = "e1"
                        oStatic = oNewItem.Specific
                        oStatic.Caption = "Transferred Status"
                        oItem = oOrderForm.Items.Item("s10")
                        oNewItem = oOrderForm.Items.Add("e10", SAPbouiCOM.BoFormItemTypes.it_EDIT)
                        oNewItem.Left = oItem.Width + oItem.Left
                        oNewItem.Width = 60 'oItem.Width
                        oNewItem.Top = oItem.Top
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oEdit = oNewItem.Specific
                        oEdit.DataBind.SetBound(True, "ORDR", "U_AB_Trnst")
                        oItem = oOrderForm.Items.Item("s10")
                        oItem.LinkTo = "e10"
                        '=============================================


                        'ComboLoad_Division(oForm, oCombo)
                        oItem = oOrderForm.Items.Item("s9")
                        oNewItem = oOrderForm.Items.Add("s11", SAPbouiCOM.BoFormItemTypes.it_STATIC)
                        oNewItem.Left = oItem.Left '+ 10 + oItem.Width
                        oNewItem.Width = oItem.Width '+ 85
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        ' oNewItem.LinkTo = "e1"
                        oStatic = oNewItem.Specific
                        oStatic.Caption = "Shipping Type"

                        oItem = oOrderForm.Items.Item("e9")
                        oNewItem = oOrderForm.Items.Add("e11", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = oItem.Width
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oCombo = oNewItem.Specific
                        oCombo.DataBind.SetBound(True, "ORDR", "U_AB_ShipType")
                        ComboLoad_ShipType(oOrderForm, oCombo)
                        oItem = oOrderForm.Items.Item("s11")
                        oItem.LinkTo = "e11"
                        '  Exit Sub

                        oItem = oOrderForm.Items.Item("s10")
                        oNewItem = oOrderForm.Items.Add("s12", SAPbouiCOM.BoFormItemTypes.it_STATIC)
                        oNewItem.Left = oItem.Left '+ 10 + oItem.Width
                        oNewItem.Width = oItem.Width ' + 20 '+ 85
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        ' oNewItem.LinkTo = "e1"
                        oStatic = oNewItem.Specific
                        oStatic.Caption = "Job No"
                        oItem = oOrderForm.Items.Item("e10")
                        oNewItem = oOrderForm.Items.Add("e12", SAPbouiCOM.BoFormItemTypes.it_EDIT)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = oItem.Width
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oEdit = oNewItem.Specific
                        oEdit.DataBind.SetBound(True, "ORDR", "U_AB_JobNo")
                        oItem = oOrderForm.Items.Item("s12")
                        oItem.LinkTo = "e12"

                        '==============

                        'ComboLoad_Division(oForm, oCombo)
                        oItem = oOrderForm.Items.Item("s11")
                        oNewItem = oOrderForm.Items.Add("s13", SAPbouiCOM.BoFormItemTypes.it_STATIC)
                        oNewItem.Left = oItem.Left '+ 10 + oItem.Width
                        oNewItem.Width = oItem.Width '+ 85
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        ' oNewItem.LinkTo = "e1"
                        oStatic = oNewItem.Specific
                        oStatic.Caption = "Destination"

                        oItem = oOrderForm.Items.Item("e11")
                        oNewItem = oOrderForm.Items.Add("e13", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = oItem.Width
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oCombo = oNewItem.Specific
                        oCombo.DataBind.SetBound(True, "ORDR", "U_AB_DestCode")
                        'GOPi
                        ComboLoad_City(oOrderForm, oCombo)
                        oItem = oOrderForm.Items.Item("s13")
                        oItem.LinkTo = "e13"
                        '  Exit Sub
                        oItem = oOrderForm.Items.Item("s12")
                        oNewItem = oOrderForm.Items.Add("e14", SAPbouiCOM.BoFormItemTypes.it_EDIT)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = oItem.Width
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oEdit = oNewItem.Specific
                        oEdit.DataBind.SetBound(True, "ORDR", "U_AB_DestName")


                        '===============================================
                        oItem = oOrderForm.Items.Item("e1")
                        oNewItem = oOrderForm.Items.Add("e2", SAPbouiCOM.BoFormItemTypes.it_EDIT)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = 80 'oItem.Width - 10
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oEdit = oNewItem.Specific
                        oEdit.DataBind.SetBound(True, "ORDR", "U_AB_VessCode")
                        oItem = oOrderForm.Items.Item("e2")
                        oNewItem = oOrderForm.Items.Add("e22", SAPbouiCOM.BoFormItemTypes.it_EDIT)
                        oNewItem.Left = oItem.Left + oItem.Width + 2
                        oNewItem.Width = 100
                        oNewItem.Top = oItem.Top
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oEdit = oNewItem.Specific
                        oEdit.DataBind.SetBound(True, "ORDR", "U_AB_VessName")

                        'ComboLoad_Division(oForm, oCombo)
                        oItem = oOrderForm.Items.Item("s1")
                        oNewItem = oOrderForm.Items.Add("s2", SAPbouiCOM.BoFormItemTypes.it_STATIC)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = oItem.Width '+ 85
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oNewItem.LinkTo = "e2"
                        oStatic = oNewItem.Specific
                        oStatic.Caption = "Vessel"
                        '  Exit Sub

                        '===============================================
                        oItem = oOrderForm.Items.Item("e2")
                        oNewItem = oOrderForm.Items.Add("e3", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = 80 'oItem.Width - 10
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oCombo = oNewItem.Specific
                        oCombo.DataBind.SetBound(True, "ORDR", "U_AB_OrginCode")
                        ComboLoad_City(oOrderForm, oCombo)
                        oItem = oOrderForm.Items.Item("e3")
                        oNewItem = oOrderForm.Items.Add("e33", SAPbouiCOM.BoFormItemTypes.it_EDIT)
                        oNewItem.Left = oItem.Left + oItem.Width + 2
                        oNewItem.Width = 100
                        oNewItem.Top = oItem.Top
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oEdit = oNewItem.Specific
                        oEdit.DataBind.SetBound(True, "ORDR", "U_AB_OriginName")
                        'ComboLoad_Division(oForm, oCombo)
                        oItem = oOrderForm.Items.Item("s2")
                        oNewItem = oOrderForm.Items.Add("s3", SAPbouiCOM.BoFormItemTypes.it_STATIC)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = oItem.Width '+ 85
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oNewItem.LinkTo = "e3"
                        oStatic = oNewItem.Specific
                        oStatic.Caption = "Origin"
                        '  Exit Sub
                        '===============================================
                        oItem = oOrderForm.Items.Item("e3")
                        oNewItem = oOrderForm.Items.Add("e4", SAPbouiCOM.BoFormItemTypes.it_EDIT)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = 300 'oItem.Width - 10
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oEdit = oNewItem.Specific
                        oEdit.DataBind.SetBound(True, "ORDR", "U_AB_Desc")
                        oItem = oOrderForm.Items.Item("s3")
                        oNewItem = oOrderForm.Items.Add("s4", SAPbouiCOM.BoFormItemTypes.it_STATIC)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = oItem.Width '+ 85
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oNewItem.LinkTo = "e3"
                        oStatic = oNewItem.Specific
                        oStatic.Caption = "Item Description"
                        '  Exit Sub
                        '=====================================================
                        oItem = oOrderForm.Items.Item("e4")
                        oNewItem = oOrderForm.Items.Add("e5", SAPbouiCOM.BoFormItemTypes.it_EDIT)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = 80 'oItem.Width - 10
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oEdit = oNewItem.Specific
                        oEdit.DataBind.SetBound(True, "ORDR", "U_AB_Validity")
                        oItem = oOrderForm.Items.Item("s4")
                        oNewItem = oOrderForm.Items.Add("s5", SAPbouiCOM.BoFormItemTypes.it_STATIC)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = oItem.Width ' + 85
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oNewItem.LinkTo = "e5"
                        oStatic = oNewItem.Specific
                        oStatic.Caption = "Validity"
                        '
                        '=====================================================
                        '  Exit Sub
                        oItem = oOrderForm.Items.Item("e5")
                        oNewItem = oOrderForm.Items.Add("e6", SAPbouiCOM.BoFormItemTypes.it_EXTEDIT)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = 300 'oItem.Width - 10
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 30
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oEdit = oNewItem.Specific
                        oEdit.DataBind.SetBound(True, "ORDR", "U_AB_JobScope")
                        oItem = oOrderForm.Items.Item("s5")
                        oNewItem = oOrderForm.Items.Add("s6", SAPbouiCOM.BoFormItemTypes.it_STATIC)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = oItem.Width '+ 85
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oNewItem.LinkTo = "e6"
                        oStatic = oNewItem.Specific
                        oStatic.Caption = "Job Scope"
                        '
                        '=====================================================
                        '  Exit Sub
                        oItem = oOrderForm.Items.Item("e6")
                        oNewItem = oOrderForm.Items.Add("e7", SAPbouiCOM.BoFormItemTypes.it_EDIT)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = 80 'oItem.Width - 10
                        oNewItem.Top = oItem.Top + 15 + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oEdit = oNewItem.Specific
                        oEdit.DataBind.SetBound(True, "ORDR", "U_AB_Ttime")
                        oItem = oOrderForm.Items.Item("s6")
                        oNewItem = oOrderForm.Items.Add("s7", SAPbouiCOM.BoFormItemTypes.it_STATIC)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = oItem.Width '+ 85
                        oNewItem.Top = oItem.Top + 15 + 14
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oNewItem.LinkTo = "e7"
                        oStatic = oNewItem.Specific
                        oStatic.Caption = "Transit Time"


                        oItem = oOrderForm.Items.Item("e7")
                        oNewItem = oOrderForm.Items.Add("e8", SAPbouiCOM.BoFormItemTypes.it_EDIT)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = 80 'oItem.Width - 10
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oEdit = oNewItem.Specific
                        oEdit.DataBind.SetBound(True, "ORDR", "U_AB_Freq")
                        oItem = oOrderForm.Items.Item("s7")
                        oNewItem = oOrderForm.Items.Add("s8", SAPbouiCOM.BoFormItemTypes.it_STATIC)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = oItem.Width '+ 85
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        oNewItem.LinkTo = "e8"
                        oStatic = oNewItem.Specific
                        oStatic.Caption = "Frequency"
                        oOrderForm.PaneLevel = 12

                        oItem = oOrderForm.Items.Item("s8")
                        oNewItem = oOrderForm.Items.Add("cs1", SAPbouiCOM.BoFormItemTypes.it_STATIC)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = oItem.Width '+ 85
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        ' oNewItem.LinkTo = "e8"
                        oStatic = oNewItem.Specific
                        oStatic.Caption = "Cargo Type"
                        oOrderForm.PaneLevel = 12


                        oItem = oOrderForm.Items.Item("e8")
                        oNewItem = oOrderForm.Items.Add("ce1", SAPbouiCOM.BoFormItemTypes.it_OPTION_BUTTON)
                        oNewItem.Left = oItem.Left
                        oNewItem.Width = 80 'oItem.Width - 10
                        oNewItem.Top = oItem.Top + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        ooption = oNewItem.Specific
                        ooption.Caption = "LCL"
                        ooption.DataBind.SetBound(True, "ORDR", "U_AB_CaType")

                        oItem = oOrderForm.Items.Item("ce1")
                        oNewItem = oOrderForm.Items.Add("ce2", SAPbouiCOM.BoFormItemTypes.it_OPTION_BUTTON)
                        oNewItem.Left = oItem.Left + oItem.Width + 10
                        oNewItem.Width = 80 'oItem.Width - 10
                        oNewItem.Top = oItem.Top ' + 15
                        oNewItem.Height = 14
                        oNewItem.FromPane = 12
                        oNewItem.ToPane = 12
                        ooption = oNewItem.Specific
                        ooption.Caption = "FCL"
                        ooption.DataBind.SetBound(True, "ORDR", "U_AB_CaType1")
                        ooption.GroupWith("ce1")

                        Salese_Order_CargoMatrix(oOrderForm)
                        Salese_Order_ContMatrix(oOrderForm)
                        oOrderForm.State = SAPbouiCOM.BoFormStateEnum.fs_Maximized


                    End If
                End If
            End If
        Catch ex As Exception
            SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)
        End Try
    End Sub
    Private Sub ComboLoad_City(ByRef Oform As SAPbouiCOM.Form, ByRef oCombo As SAPbouiCOM.ComboBox)
        Try
            oRecordSet = Ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
            oRecordSet.DoQuery("SELECT T0.[Code], T0.[Name] FROM OCRY T0 order by T0.COde")
            Dim it As Integer = 1
            For it = oCombo.ValidValues.Count - 1 To 0 Step -1
                oCombo.ValidValues.Remove(it, SAPbouiCOM.BoSearchKey.psk_Index)
            Next
            Do While Not oRecordSet.EoF
                oCombo.ValidValues.Add(oRecordSet.Fields.Item(0).Value, oRecordSet.Fields.Item(1).Value)
                oRecordSet.MoveNext()
            Loop
            oRecordSet = Nothing
            GC.Collect()
        Catch ex As Exception
            SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
        End Try
    End Sub
    Private Sub ComboLoad_TransferTo(ByRef Oform As SAPbouiCOM.Form, ByRef oCombo As SAPbouiCOM.ComboBox)
        Try
            oRecordSet = Ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
            oRecordSet.DoQuery("SELECT T0.[Code], T0.[Name] FROM [@AB_TRANSFERTO] T0 order by T0.COde")
            Dim it As Integer = 1
            For it = oCombo.ValidValues.Count - 1 To 0 Step -1
                oCombo.ValidValues.Remove(it, SAPbouiCOM.BoSearchKey.psk_Index)
            Next
            Do While Not oRecordSet.EoF
                oCombo.ValidValues.Add(oRecordSet.Fields.Item(0).Value, oRecordSet.Fields.Item(1).Value)
                oRecordSet.MoveNext()
            Loop
            oRecordSet = Nothing
            GC.Collect()
        Catch ex As Exception
            SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
        End Try
    End Sub
    Private Sub ComboLoad_ShipType(ByRef Oform As SAPbouiCOM.Form, ByRef oCombo As SAPbouiCOM.ComboBox)
        Try
            oRecordSet = Ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
            oRecordSet.DoQuery("SELECT T0.[TrnspName], T0.[TrnspCode] FROM OSHP T0 ORDER BY T0.[TrnspName]")
            Dim it As Integer = 1
            For it = oCombo.ValidValues.Count - 1 To 0 Step -1
                oCombo.ValidValues.Remove(it, SAPbouiCOM.BoSearchKey.psk_Index)
            Next
            Do While Not oRecordSet.EoF
                oCombo.ValidValues.Add(oRecordSet.Fields.Item(0).Value, oRecordSet.Fields.Item(1).Value)
                oRecordSet.MoveNext()
            Loop
            oRecordSet = Nothing
            GC.Collect()
        Catch ex As Exception
            SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
        End Try
    End Sub
    Public Sub Salese_Order_ContMatrix(ByVal Oform As SAPbouiCOM.Form)
        Try

            oNewItem = oOrderForm.Items.Add("Cont", SAPbouiCOM.BoFormItemTypes.it_FOLDER)
            oItem = oOrderForm.Items.Item("Cargo")
            oNewItem.Top = oItem.Top
            oNewItem.Height = oItem.Height
            oNewItem.Width = oItem.Width
            oNewItem.Left = oItem.Left + oItem.Width + 5
            oFolderItem = oNewItem.Specific
            oFolderItem.Caption = "Container Details"
            oFolderItem.GroupWith("Cargo")
            oFolderItem.Pane = 15
            'oFolderItem.Select()
            oItem = oOrderForm.Items.Item("38")
            oNewItem = Oform.Items.Add("MATCont", SAPbouiCOM.BoFormItemTypes.it_MATRIX)
            oNewItem.Left = oItem.Left
            oNewItem.Width = oItem.Width
            oNewItem.Top = oItem.Top
            oNewItem.Height = oItem.Height
            oNewItem.FromPane = 15
            oNewItem.ToPane = 15
            oMatrix1 = oNewItem.Specific
            oColumns = oMatrix1.Columns
            oColumn = oColumns.Add("#", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "#"
            oColumn.Width = 30
            oColumn.Editable = False
            Oform.DataSources.UserDataSources.Add("LineNo", SAPbouiCOM.BoDataType.dt_SHORT_NUMBER)
            oColumn = oColumns.Item("#")
            oColumn.DataBind.SetBound(True, "", "LineNo")
            '

            oColumn = oColumns.Add("ContNo", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Container No"
            oColumn.Width = 40
            oColumn.Editable = True
            Oform.DataSources.UserDataSources.Add("ContNo", SAPbouiCOM.BoDataType.dt_SHORT_TEXT)
            oColumn = oColumns.Item("ContNo")
            oColumn.DataBind.SetBound(True, "", "ContNo")

            oColumn = oColumns.Add("Size", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Size/Type"
            oColumn.Width = 40
            oColumn.Editable = True
            Oform.DataSources.UserDataSources.Add("Size", SAPbouiCOM.BoDataType.dt_SHORT_TEXT)
            oColumn = oColumns.Item("Size")
            oColumn.DataBind.SetBound(True, "", "Size")


            oColumn = oColumns.Add("Wt", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Weight"
            oColumn.Width = 40
            oColumn.Editable = True
            Oform.DataSources.UserDataSources.Add("Wt1", SAPbouiCOM.BoDataType.dt_MEASURE)
            oColumn = oColumns.Item("Wt")
            oColumn.DataBind.SetBound(True, "", "Wt1")
            oColumn = oColumns.Add("SealNo", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Seal No"
            oColumn.Width = 40
            oColumn.Editable = True
            Oform.DataSources.UserDataSources.Add("SealNo", SAPbouiCOM.BoDataType.dt_SHORT_TEXT)
            oColumn = oColumns.Item("SealNo")
            oColumn.DataBind.SetBound(True, "", "SealNo")

            oMatrix1.AddRow()
            oMatrix1.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Auto
            ' oMatrix1.Clear()

        Catch ex As Exception
            SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)
        End Try
    End Sub
    Public Sub Salese_Order_CargoMatrix(ByVal Oform As SAPbouiCOM.Form)
        Try

            oNewItem = oOrderForm.Items.Add("Cargo", SAPbouiCOM.BoFormItemTypes.it_FOLDER)
            oItem = oOrderForm.Items.Item("Genera1")
            oNewItem.Top = oItem.Top
            oNewItem.Height = oItem.Height
            oNewItem.Width = oItem.Width
            oNewItem.Left = oItem.Left + oItem.Width + 5
            oFolderItem = oNewItem.Specific
            oFolderItem.Caption = "Cargo Details"
            oFolderItem.GroupWith("Genera1")
            oFolderItem.Pane = 13
            'oFolderItem.Select()


            oItem = oOrderForm.Items.Item("38")
            oNewItem = Oform.Items.Add("MATCargo", SAPbouiCOM.BoFormItemTypes.it_MATRIX)
            oNewItem.Left = oItem.Left
            oNewItem.Width = oItem.Width
            oNewItem.Top = oItem.Top
            oNewItem.Height = oItem.Height
            oNewItem.FromPane = 13
            oNewItem.ToPane = 13
            oMatrix = oNewItem.Specific
            oColumns = oMatrix.Columns
            oColumn = oColumns.Add("#", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "#"
            oColumn.Width = 30
            oColumn.Editable = False
            Oform.DataSources.UserDataSources.Add("V_-1", SAPbouiCOM.BoDataType.dt_SHORT_NUMBER)
            oColumn = oColumns.Item("#")
            oColumn.DataBind.SetBound(True, "", "V_-1")
            '

            oColumn = oColumns.Add("SupCode", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Supplier Code"
            oColumn.Width = 40
            oColumn.Editable = True
            Oform.DataSources.UserDataSources.Add("SupCode", SAPbouiCOM.BoDataType.dt_SHORT_TEXT)
            oColumn = oColumns.Item("SupCode")
            oColumn.DataBind.SetBound(True, "", "SupCode")

            oColumn = oColumns.Add("SupName", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Supplier Name"
            oColumn.Width = 40
            oColumn.Editable = True
            Oform.DataSources.UserDataSources.Add("SupName", SAPbouiCOM.BoDataType.dt_SHORT_TEXT)
            oColumn = oColumns.Item("SupName")
            oColumn.DataBind.SetBound(True, "", "SupName")


            oColumn = oColumns.Add("PONo", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "PO No"
            oColumn.Width = 40
            oColumn.Editable = True
            Oform.DataSources.UserDataSources.Add("PONo", SAPbouiCOM.BoDataType.dt_SHORT_TEXT)
            oColumn = oColumns.Item("PONo")
            oColumn.DataBind.SetBound(True, "", "PONo")

            oColumn = oColumns.Add("Pkg", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Pcks #"
            oColumn.Width = 40
            oColumn.Editable = True
            Oform.DataSources.UserDataSources.Add("Pkg", SAPbouiCOM.BoDataType.dt_SHORT_NUMBER)
            oColumn = oColumns.Item("Pkg")
            oColumn.DataBind.SetBound(True, "", "Pkg")

            oColumn = oColumns.Add("PkgT", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Pkg. Type"
            oColumn.Width = 40
            oColumn.Editable = True
            Oform.DataSources.UserDataSources.Add("PkgT", SAPbouiCOM.BoDataType.dt_SHORT_TEXT)
            oColumn = oColumns.Item("PkgT")
            oColumn.DataBind.SetBound(True, "", "PkgT")

            oColumn = oColumns.Add("Wt", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Wt(kgs)"
            oColumn.Width = 40
            oColumn.Editable = True
            Oform.DataSources.UserDataSources.Add("Wt", SAPbouiCOM.BoDataType.dt_MEASURE)
            oColumn = oColumns.Item("Wt")
            oColumn.DataBind.SetBound(True, "", "Wt")

            oColumn = oColumns.Add("L", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "L(cms)"
            oColumn.Width = 40
            oColumn.Editable = True
            Oform.DataSources.UserDataSources.Add("L", SAPbouiCOM.BoDataType.dt_SHORT_NUMBER)
            oColumn = oColumns.Item("L")
            oColumn.DataBind.SetBound(True, "", "L")

            oColumn = oColumns.Add("W", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "W(cms)"
            oColumn.Width = 40
            oColumn.Editable = True
            Oform.DataSources.UserDataSources.Add("W", SAPbouiCOM.BoDataType.dt_SHORT_NUMBER)
            oColumn = oColumns.Item("W")
            oColumn.DataBind.SetBound(True, "", "W")

            oColumn = oColumns.Add("H", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "H(cms)"
            oColumn.Width = 40
            oColumn.Editable = True

            Oform.DataSources.UserDataSources.Add("H", SAPbouiCOM.BoDataType.dt_SHORT_NUMBER)
            oColumn = oColumns.Item("H")
            oColumn.DataBind.SetBound(True, "", "H")

            oColumn = oColumns.Add("m3", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "m3"
            oColumn.Width = 40
            oColumn.Editable = True

            Oform.DataSources.UserDataSources.Add("m3", SAPbouiCOM.BoDataType.dt_MEASURE)
            oColumn = oColumns.Item("m3")
            oColumn.DataBind.SetBound(True, "", "m3")

            oColumn = oColumns.Add("vol", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Vol/Wt"
            oColumn.Width = 40
            oColumn.Editable = True

            Oform.DataSources.UserDataSources.Add("vol", SAPbouiCOM.BoDataType.dt_MEASURE)
            oColumn = oColumns.Item("vol")
            oColumn.DataBind.SetBound(True, "", "vol")

            oColumn = oColumns.Add("Desc", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Description"
            oColumn.Width = 40
            oColumn.Editable = True
            Oform.DataSources.UserDataSources.Add("Desc", SAPbouiCOM.BoDataType.dt_SHORT_TEXT)
            oColumn = oColumns.Item("Desc")
            oColumn.DataBind.SetBound(True, "", "Desc")
            oMatrix.AddRow()
            oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Auto
            'oMatrix.Clear()
        Catch ex As Exception
            SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)
        End Try
    End Sub
    Private Sub Add_Container_details(ByVal oForm As SAPbouiCOM.Form)
        Try
            Dim oGeneralService As SAPbobsCOM.GeneralService
            Dim oGeneralData As SAPbobsCOM.GeneralData
            Dim sCmp As SAPbobsCOM.CompanyService
            sCmp = Ocompany.GetCompanyService
            Dim DocNum As String = ""
            Dim LineNo As Integer = 0
            Dim ContNo As String = ""
            Dim Size As String = ""
            Dim Wt As Double = 0.0
            Dim SealNo As String = ""
            oGeneralService = sCmp.GetGeneralService("AB_SALESORDER_CONT")
            oGeneralData = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)
            Dim i As Integer = 1
            oMatrix1 = oForm.Items.Item("MATCont").Specific
            oColumns = oMatrix1.Columns
            oCombo = oForm.Items.Item("88").Specific
            Dim series As String = oCombo.Selected.Value
            oRecordSet1 = Ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
            oRecordSet1.DoQuery("SELECT T0.[ObjectCode], T0.[Series], T0.[SeriesName], T0.[InitialNum], T0.[NextNumber], T0.[LastNum], T0.[BeginStr], T0.[EndStr] FROM NNM1 T0 WHERE T0.[ObjectCode] =17 and T0.[Series]='" & series & "'")
            DocNum = oRecordSet1.Fields.Item("NextNumber").Value
            For i = 1 To oMatrix1.RowCount
                oEdit = oMatrix1.Columns.Item("ContNo").Cells.Item(i).Specific
                ContNo = oEdit.String
                oEdit = oMatrix1.Columns.Item("Size").Cells.Item(i).Specific
                Size = oEdit.String
                oEdit = oMatrix1.Columns.Item("Wt").Cells.Item(i).Specific
                If oEdit.String <> "" Then
                    Wt = oEdit.Value
                Else
                    Wt = 0
                End If


                oEdit = oMatrix1.Columns.Item("SealNo").Cells.Item(i).Specific
                SealNo = oEdit.String
                If ContNo <> "" Then
                    oGeneralData.SetProperty("U_SONo", DocNum)
                    oGeneralData.SetProperty("U_LineNo", i)
                    oGeneralData.SetProperty("U_ContNo", ContNo)
                    oGeneralData.SetProperty("U_Size", Size)
                    oGeneralData.SetProperty("U_Wt", Wt)
                    oGeneralData.SetProperty("U_SealNo", SealNo)
                    Try
                        oGeneralService.Add(oGeneralData)
                    Catch ex As Exception
                        SBO_Application.StatusBar.SetText("Error: Add_Container_details-" & ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
                    End Try
                End If

            Next
            oMatrix1.Clear()
        Catch ex As Exception
            SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)
        End Try
    End Sub
    Private Sub Get_Container_details(ByVal oForm As SAPbouiCOM.Form)
        Try

            oForm.Freeze(True)
            oEdit = oForm.Items.Item("8").Specific
            Dim sqlstr As String = "SELECT T0.[U_LineNo]  ,T0.[U_ContNo] , T0.[U_Size] , T0.[U_Wt]  ,T0.[U_SealNo] FROM [dbo].[@AB_SALESORDER_CONT]  T0 WHERE T0.[U_SONo]='" & oEdit.String & "' ORDER BY T0.[U_LineNo], T0.[DocEntry]"
            oForm.DataSources.DataTables.Item("OCARGO").ExecuteQuery(sqlstr)
            oMatrix = oForm.Items.Item("MATCont").Specific
            oMatrix.Clear()
            oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_None
            oColumns = oMatrix.Columns
            oForm.Items.Item("MATCont").Specific.Columns.item("#").DataBind.Bind("OCARGO", "U_LineNo")
            oForm.Items.Item("MATCont").Specific.Columns.item("ContNo").DataBind.Bind("OCARGO", "U_ContNo")
            oForm.Items.Item("MATCont").Specific.Columns.item("Size").DataBind.Bind("OCARGO", "U_Size")
            oForm.Items.Item("MATCont").Specific.Columns.item("Wt").DataBind.Bind("OCARGO", "U_Wt")
            oForm.Items.Item("MATCont").Specific.Columns.item("SealNo").DataBind.Bind("OCARGO", "U_SealNo")
            oForm.Items.Item("MATCont").Specific.Clear()
            oForm.Items.Item("MATCont").Specific.LoadFromDataSource()
            oForm.Items.Item("MATCont").Specific.AutoResizeColumns()
            oForm.Freeze(False)
        Catch ex As Exception
            oForm.Freeze(False)
            SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)
        End Try
    End Sub
    Private Sub Update_Container_details(ByVal oForm As SAPbouiCOM.Form)
        Try
            Dim oGeneralService As SAPbobsCOM.GeneralService
            Dim oGeneralData As SAPbobsCOM.GeneralData
            Dim sCmp As SAPbobsCOM.CompanyService
            sCmp = Ocompany.GetCompanyService
            Dim DocNum As String = ""
            Dim LineNo As Integer = 0
            Dim ContNo As String = ""
            Dim Size As String = ""
            Dim Wt As Double = 0.0
            Dim SealNo As String = ""
            oGeneralService = sCmp.GetGeneralService("AB_SALESORDER_CONT")
            oGeneralData = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)
            Dim oHeaderParams1 As SAPbobsCOM.GeneralDataParams
            oHeaderParams1 = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)
            Dim oRecordSet_EC1 As SAPbobsCOM.Recordset
            oRecordSet_EC1 = Ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
           
            Dim i As Integer = 1
            oMatrix1 = oForm.Items.Item("MATCont").Specific
            oColumns = oMatrix1.Columns
            oCombo = oForm.Items.Item("88").Specific
            Dim series As String = oCombo.Selected.Value
            oRecordSet1 = Ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
            oRecordSet1.DoQuery("SELECT T0.[ObjectCode], T0.[Series], T0.[SeriesName], T0.[InitialNum], T0.[NextNumber], T0.[LastNum], T0.[BeginStr], T0.[EndStr] FROM NNM1 T0 WHERE T0.[ObjectCode] =17 and T0.[Series]='" & series & "'")
            DocNum = oRecordSet1.Fields.Item("NextNumber").Value
            oEdit = oForm.Items.Item("8").Specific
            Dim SODocNo As String = oEdit.String
            For i = 1 To oMatrix1.RowCount
                oRecordSet_EC1.DoQuery("SELECT T0.[DocEntry] FROM [dbo].[@AB_SALESORDER_CONT]  T0 WHERE T0.[U_SONo] ='" & SODocNo & "' and  T0.[U_LineNo] ='" & i & "'")
                If oRecordSet_EC1.RecordCount > 0 Then '--update udo
                    oHeaderParams1.SetProperty("DocEntry", oRecordSet_EC1.Fields.Item(0).Value.ToString.Trim()) '
                    oGeneralData = oGeneralService.GetByParams(oHeaderParams1)
                    oEdit = oMatrix1.Columns.Item("ContNo").Cells.Item(i).Specific
                    ContNo = oEdit.String
                    oEdit = oMatrix1.Columns.Item("Size").Cells.Item(i).Specific
                    Size = oEdit.String
                    oEdit = oMatrix1.Columns.Item("Wt").Cells.Item(i).Specific
                    If oEdit.String <> "" Then
                        Wt = oEdit.Value
                    Else
                        Wt = 0
                    End If

                    oEdit = oMatrix1.Columns.Item("SealNo").Cells.Item(i).Specific
                    SealNo = oEdit.String
                    ' If ContNo <> "" Then
                    'oGeneralData.SetProperty("U_SONo", DocNum)
                    'oGeneralData.SetProperty("U_LineNo", i)
                    oGeneralData.SetProperty("U_ContNo", ContNo)
                    oGeneralData.SetProperty("U_Size", Size)
                    oGeneralData.SetProperty("U_Wt", Wt)
                    oGeneralData.SetProperty("U_SealNo", SealNo)
                    Try
                        oGeneralService.Update(oGeneralData)
                    Catch ex As Exception
                        SBO_Application.StatusBar.SetText("Error: Add_Container_details-" & ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
                    End Try
                    'End If

                Else '---add udo
                    oEdit = oMatrix1.Columns.Item("ContNo").Cells.Item(i).Specific
                    ContNo = oEdit.String
                    oEdit = oMatrix1.Columns.Item("Size").Cells.Item(i).Specific
                    Size = oEdit.String
                    oEdit = oMatrix1.Columns.Item("Wt").Cells.Item(i).Specific
                    Wt = oEdit.Value
                    oEdit = oMatrix1.Columns.Item("SealNo").Cells.Item(i).Specific
                    SealNo = oEdit.String
                    If ContNo <> "" Then
                        oGeneralData.SetProperty("U_SONo", DocNum)
                        oGeneralData.SetProperty("U_LineNo", i)
                        oGeneralData.SetProperty("U_ContNo", ContNo)
                        oGeneralData.SetProperty("U_Size", Size)
                        oGeneralData.SetProperty("U_Wt", Wt)
                        oGeneralData.SetProperty("U_SealNo", SealNo)
                        Try
                            oGeneralService.Add(oGeneralData)
                        Catch ex As Exception
                            SBO_Application.StatusBar.SetText("Error: Add_Container_details-" & ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
                        End Try
                    End If


                End If
            Next
            ' oMatrix1.Clear()
        Catch ex As Exception
            SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)
        End Try
    End Sub
    Private Sub Add_Cargo_details(ByVal oForm As SAPbouiCOM.Form)
        Try
            Dim oGeneralService As SAPbobsCOM.GeneralService
            Dim oGeneralData As SAPbobsCOM.GeneralData
            Dim sCmp As SAPbobsCOM.CompanyService
            sCmp = Ocompany.GetCompanyService
            Dim DocNum As String = ""
            Dim LineNo As Integer = 0
            Dim SUppCOde As String = ""
            Dim SUppName As String = ""
            Dim PONo As String = ""
            Dim Pkg As Integer = 0
            Dim PType As String = ""
            Dim Wt As Double = 0
            Dim L As Integer = 0
            Dim w As Integer = 0
            Dim H As Integer = 0
            Dim m3 As Double = 0
            Dim vol As Double = 0
            Dim Desc As String = 0

            oGeneralService = sCmp.GetGeneralService("AB_SALESORDER_CARGO")
            oGeneralData = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)
            Dim i As Integer = 1
            oMatrix = oForm.Items.Item("MATCargo").Specific
            oColumns = oMatrix.Columns
            oCombo = oForm.Items.Item("88").Specific
            Dim series As String = oCombo.Selected.Value
            oRecordSet1 = Ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
            oRecordSet1.DoQuery("SELECT T0.[ObjectCode], T0.[Series], T0.[SeriesName], T0.[InitialNum], T0.[NextNumber], T0.[LastNum], T0.[BeginStr], T0.[EndStr] FROM NNM1 T0 WHERE T0.[ObjectCode] =17 and T0.[Series]='" & series & "'")
            DocNum = oRecordSet1.Fields.Item("NextNumber").Value
            For i = 1 To oMatrix.RowCount
                oEdit = oMatrix.Columns.Item("SupCode").Cells.Item(i).Specific
                SUppCOde = oEdit.String
                oEdit = oMatrix.Columns.Item("SupName").Cells.Item(i).Specific
                SUppName = oEdit.String
                oEdit = oMatrix.Columns.Item("PONo").Cells.Item(i).Specific
                If oEdit.String <> "" Then
                    PONo = oEdit.Value
                Else
                    PONo = ""
                End If

                oEdit = oMatrix.Columns.Item("Pkg").Cells.Item(i).Specific
                If oEdit.String <> "" Then
                    Pkg = oEdit.Value
                Else
                    Pkg = 0
                End If

                oEdit = oMatrix.Columns.Item("PkgT").Cells.Item(i).Specific
                PType = oEdit.String
                oEdit = oMatrix.Columns.Item("Wt").Cells.Item(i).Specific
                If oEdit.String <> "" Then
                    Wt = oEdit.Value
                Else
                    Wt = 0
                End If

                oEdit = oMatrix.Columns.Item("L").Cells.Item(i).Specific
                If oEdit.String <> "" Then
                    L = oEdit.Value
                Else
                    L = 0
                End If

                oEdit = oMatrix.Columns.Item("W").Cells.Item(i).Specific
                If oEdit.String <> "" Then
                    w = oEdit.Value
                Else
                    w = 0
                End If

                oEdit = oMatrix.Columns.Item("H").Cells.Item(i).Specific
                If oEdit.String <> "" Then
                    H = oEdit.Value
                Else
                    H = 0
                End If
                oEdit = oMatrix.Columns.Item("m3").Cells.Item(i).Specific
                If oEdit.String <> "" Then
                    m3 = oEdit.Value
                Else
                    m3 = 0
                End If

                oEdit = oMatrix.Columns.Item("vol").Cells.Item(i).Specific
                If (oEdit.String <> "") Then
                    vol = oEdit.Value
                Else
                    vol = 0
                End If
                oEdit = oMatrix.Columns.Item("Desc").Cells.Item(i).Specific
                Desc = oEdit.String
                If SUppCOde <> "" Then
                    oGeneralData.SetProperty("U_SONo", DocNum)
                    oGeneralData.SetProperty("U_LineNo", i)
                    oGeneralData.SetProperty("U_VenCode", SUppCOde)
                    oGeneralData.SetProperty("U_VenName", SUppName)
                    oGeneralData.SetProperty("U_PONO", PONo)
                    oGeneralData.SetProperty("U_PKg", Pkg)
                    oGeneralData.SetProperty("U_PkgType", PType)
                    oGeneralData.SetProperty("U_Wt", Wt)
                    oGeneralData.SetProperty("U_Len", L)
                    oGeneralData.SetProperty("U_Width", w)
                    oGeneralData.SetProperty("U_Height", H)
                    oGeneralData.SetProperty("U_M3", m3)
                    oGeneralData.SetProperty("U_Vol", vol)
                    oGeneralData.SetProperty("U_Desc", Desc)
                    Try
                        oGeneralService.Add(oGeneralData)
                    Catch ex As Exception
                        SBO_Application.StatusBar.SetText("Error: Add_Container_details-" & ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
                    End Try
                End If

            Next
            oMatrix.Clear()
        Catch ex As Exception
            SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)
        End Try
    End Sub
    Private Sub Get_Cargo_details(ByVal oForm As SAPbouiCOM.Form)
        Try

            oForm.Freeze(True)
            oEdit = oForm.Items.Item("8").Specific
            Dim sqlstr As String = "SELECT T0.[U_LineNo], T0.[U_VenCode], T0.[U_VenName], T0.[U_PONO], T0.[U_PKg], T0.[U_PkgType], T0.[U_Wt], T0.[U_Len], T0.[U_Width], T0.[U_Height], T0.[U_M3], T0.[U_Vol], T0.[U_Desc] FROM [dbo].[@AB_SALESORDER_CARGO]  T0 WHERE T0.[U_SONo] ='" & oEdit.String & "' ORDER BY T0.[U_LineNo], T0.[DocEntry]"
            oForm.DataSources.DataTables.Item("OCARGO1").ExecuteQuery(sqlstr)
            oMatrix1 = oForm.Items.Item("MATCargo").Specific
            oMatrix1.Clear()
            oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_None
            oColumns = oMatrix.Columns
            oForm.Items.Item("MATCargo").Specific.Columns.item("#").DataBind.Bind("OCARGO1", "U_LineNo")
            oForm.Items.Item("MATCargo").Specific.Columns.item("SupCode").DataBind.Bind("OCARGO1", "U_VenCode")
            oForm.Items.Item("MATCargo").Specific.Columns.item("SupName").DataBind.Bind("OCARGO1", "U_VenName")
            oForm.Items.Item("MATCargo").Specific.Columns.item("PONo").DataBind.Bind("OCARGO1", "U_PONO")
            oForm.Items.Item("MATCargo").Specific.Columns.item("Pkg").DataBind.Bind("OCARGO1", "U_PKg")

            oForm.Items.Item("MATCargo").Specific.Columns.item("PkgT").DataBind.Bind("OCARGO1", "U_PkgType")
            oForm.Items.Item("MATCargo").Specific.Columns.item("Wt").DataBind.Bind("OCARGO1", "U_Wt")
            oForm.Items.Item("MATCargo").Specific.Columns.item("L").DataBind.Bind("OCARGO1", "U_Len")
            oForm.Items.Item("MATCargo").Specific.Columns.item("W").DataBind.Bind("OCARGO1", "U_Width")
            oForm.Items.Item("MATCargo").Specific.Columns.item("H").DataBind.Bind("OCARGO1", "U_Height")

            oForm.Items.Item("MATCargo").Specific.Columns.item("m3").DataBind.Bind("OCARGO1", "U_M3")
            oForm.Items.Item("MATCargo").Specific.Columns.item("vol").DataBind.Bind("OCARGO1", "U_Vol")
            oForm.Items.Item("MATCargo").Specific.Columns.item("Desc").DataBind.Bind("OCARGO1", "U_Desc")

            oForm.Items.Item("MATCargo").Specific.Clear()
            oForm.Items.Item("MATCargo").Specific.LoadFromDataSource()
            oForm.Items.Item("MATCargo").Specific.AutoResizeColumns()
            oForm.Freeze(False)
        Catch ex As Exception
            oForm.Freeze(False)
            SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)
        End Try
    End Sub

    Private Sub Update_Cargo_details(ByVal oForm As SAPbouiCOM.Form)
        Try
            Dim oGeneralService As SAPbobsCOM.GeneralService
            Dim oGeneralData As SAPbobsCOM.GeneralData
            Dim sCmp As SAPbobsCOM.CompanyService
            sCmp = Ocompany.GetCompanyService
            Dim DocNum As String = ""
            Dim LineNo As Integer = 0
            Dim SUppCOde As String = ""
            Dim SUppName As String = ""
            Dim PONo As String = ""
            Dim Pkg As Integer = 0
            Dim PType As String = ""
            Dim Wt As Double = 0
            Dim L As Integer = 0
            Dim w As Integer = 0
            Dim H As Integer = 0
            Dim m3 As Double = 0
            Dim vol As Double = 0
            Dim Desc As String = ""
            oGeneralService = sCmp.GetGeneralService("AB_SALESORDER_CARGO")
            oGeneralData = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)
            Dim oHeaderParams1 As SAPbobsCOM.GeneralDataParams
            oHeaderParams1 = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)
            Dim oRecordSet_EC1 As SAPbobsCOM.Recordset
            oRecordSet_EC1 = Ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

            Dim i As Integer = 1
            oMatrix = oForm.Items.Item("MATCargo").Specific
            oColumns = oMatrix.Columns
            oCombo = oForm.Items.Item("88").Specific
            Dim series As String = oCombo.Selected.Value
            oRecordSet1 = Ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
            oRecordSet1.DoQuery("SELECT T0.[ObjectCode], T0.[Series], T0.[SeriesName], T0.[InitialNum], T0.[NextNumber], T0.[LastNum], T0.[BeginStr], T0.[EndStr] FROM NNM1 T0 WHERE T0.[ObjectCode] =17 and T0.[Series]='" & series & "'")
            DocNum = oRecordSet1.Fields.Item("NextNumber").Value
            oEdit = oForm.Items.Item("8").Specific
            Dim SODocNo As String = oEdit.String
            For i = 1 To oMatrix.RowCount
                oRecordSet_EC1.DoQuery("SELECT T0.[DocEntry] FROM [dbo].[@AB_SALESORDER_CARGO]  T0 WHERE T0.[U_SONo] ='" & SODocNo & "' and  T0.[U_LineNo] ='" & i & "'")
                If oRecordSet_EC1.RecordCount > 0 Then '--update udo
                    oHeaderParams1.SetProperty("DocEntry", oRecordSet_EC1.Fields.Item(0).Value.ToString.Trim()) '
                    oGeneralData = oGeneralService.GetByParams(oHeaderParams1)

                    oEdit = oMatrix.Columns.Item("SupCode").Cells.Item(i).Specific
                    SUppCOde = oEdit.String
                    oEdit = oMatrix.Columns.Item("SupName").Cells.Item(i).Specific
                    SUppName = oEdit.String
                    oEdit = oMatrix.Columns.Item("PONo").Cells.Item(i).Specific
                    If oEdit.String <> "" Then
                        PONo = oEdit.Value
                    Else
                        PONo = ""
                    End If

                    oEdit = oMatrix.Columns.Item("Pkg").Cells.Item(i).Specific
                    If oEdit.String <> "" Then
                        Pkg = oEdit.Value
                    Else
                        Pkg = 0
                    End If

                    oEdit = oMatrix.Columns.Item("PkgT").Cells.Item(i).Specific
                    PType = oEdit.String
                    oEdit = oMatrix.Columns.Item("Wt").Cells.Item(i).Specific
                    If oEdit.String <> "" Then
                        Wt = oEdit.Value
                    Else
                        Wt = 0
                    End If

                    oEdit = oMatrix.Columns.Item("L").Cells.Item(i).Specific
                    If oEdit.String <> "" Then
                        L = oEdit.Value
                    Else
                        L = 0
                    End If

                    oEdit = oMatrix.Columns.Item("W").Cells.Item(i).Specific
                    If oEdit.String <> "" Then
                        w = oEdit.Value
                    Else
                        w = 0
                    End If

                    oEdit = oMatrix.Columns.Item("H").Cells.Item(i).Specific
                    If oEdit.String <> "" Then
                        H = oEdit.Value
                    Else
                        H = 0
                    End If
                    oEdit = oMatrix.Columns.Item("m3").Cells.Item(i).Specific
                    If oEdit.String <> "" Then
                        m3 = oEdit.Value
                    Else
                        m3 = 0
                    End If

                    oEdit = oMatrix.Columns.Item("vol").Cells.Item(i).Specific
                    If (oEdit.String <> "") Then
                        vol = oEdit.Value
                    Else
                        vol = 0
                    End If
                    oEdit = oMatrix.Columns.Item("Desc").Cells.Item(i).Specific
                    Desc = oEdit.String
                    If SUppCOde <> "" Then
                        'oGeneralData.SetProperty("U_SONo", SODocNo)
                        'oGeneralData.SetProperty("U_LineNo", i)
                        oGeneralData.SetProperty("U_VenCode", SUppCOde)
                        oGeneralData.SetProperty("U_VenName", SUppName)
                        oGeneralData.SetProperty("U_PONO", PONo)
                        oGeneralData.SetProperty("U_PKg", Pkg)
                        oGeneralData.SetProperty("U_PkgType", PType)
                        oGeneralData.SetProperty("U_Wt", Wt)
                        oGeneralData.SetProperty("U_Len", L)
                        oGeneralData.SetProperty("U_Width", w)
                        oGeneralData.SetProperty("U_Height", H)
                        oGeneralData.SetProperty("U_M3", m3)
                        oGeneralData.SetProperty("U_Vol", vol)
                        oGeneralData.SetProperty("U_Desc", Desc)
                        Try
                            oGeneralService.Update(oGeneralData)
                        Catch ex As Exception
                            SBO_Application.StatusBar.SetText("Error: Add_Container_details-" & ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
                        End Try
                    End If


                Else '---add udo

                    oEdit = oMatrix.Columns.Item("SupCode").Cells.Item(i).Specific
                    SUppCOde = oEdit.String
                    oEdit = oMatrix.Columns.Item("SupName").Cells.Item(i).Specific
                    SUppName = oEdit.String
                    oEdit = oMatrix.Columns.Item("PONo").Cells.Item(i).Specific
                    If oEdit.String <> "" Then
                        PONo = oEdit.Value
                    Else
                        PONo = ""
                    End If

                    oEdit = oMatrix.Columns.Item("Pkg").Cells.Item(i).Specific
                    If oEdit.String <> "" Then
                        Pkg = oEdit.Value
                    Else
                        Pkg = 0
                    End If

                    oEdit = oMatrix.Columns.Item("PkgT").Cells.Item(i).Specific
                    PType = oEdit.String
                    oEdit = oMatrix.Columns.Item("Wt").Cells.Item(i).Specific
                    If oEdit.String <> "" Then
                        Wt = oEdit.Value
                    Else
                        Wt = 0
                    End If

                    oEdit = oMatrix.Columns.Item("L").Cells.Item(i).Specific
                    If oEdit.String <> "" Then
                        L = oEdit.Value
                    Else
                        L = 0
                    End If

                    oEdit = oMatrix.Columns.Item("W").Cells.Item(i).Specific
                    If oEdit.String <> "" Then
                        w = oEdit.Value
                    Else
                        w = 0
                    End If

                    oEdit = oMatrix.Columns.Item("H").Cells.Item(i).Specific
                    If oEdit.String <> "" Then
                        H = oEdit.Value
                    Else
                        H = 0
                    End If
                    oEdit = oMatrix.Columns.Item("m3").Cells.Item(i).Specific
                    If oEdit.String <> "" Then
                        m3 = oEdit.Value
                    Else
                        m3 = 0
                    End If

                    oEdit = oMatrix.Columns.Item("vol").Cells.Item(i).Specific
                    If (oEdit.String <> "") Then
                        vol = oEdit.Value
                    Else
                        vol = 0
                    End If
                    oEdit = oMatrix.Columns.Item("Desc").Cells.Item(i).Specific
                    Desc = oEdit.String
                    If SUppCOde <> "" Then
                        oGeneralData.SetProperty("U_SONo", DocNum)
                        oGeneralData.SetProperty("U_LineNo", i)
                        oGeneralData.SetProperty("U_VenCode", SUppCOde)
                        oGeneralData.SetProperty("U_VenName", SUppName)
                        oGeneralData.SetProperty("U_PONO", PONo)
                        oGeneralData.SetProperty("U_PKg", Pkg)
                        oGeneralData.SetProperty("U_PkgType", PType)
                        oGeneralData.SetProperty("U_Wt", Wt)
                        oGeneralData.SetProperty("U_Len", L)
                        oGeneralData.SetProperty("U_Width", w)
                        oGeneralData.SetProperty("U_Height", H)
                        oGeneralData.SetProperty("U_M3", m3)
                        oGeneralData.SetProperty("U_Vol", vol)
                        oGeneralData.SetProperty("U_Desc", Desc)
                        Try
                            oGeneralService.Update(oGeneralData)
                        Catch ex As Exception
                            SBO_Application.StatusBar.SetText("Error: Add_Container_details-" & ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
                        End Try
                    End If

                End If
            Next
            ' oMatrix1.Clear()
        Catch ex As Exception
            SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)
        End Try
    End Sub
End Class
